From 73004d34e4efc04bf0fc798615202361b39dd9a8 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Mon, 10 Apr 2006 17:16:25 +0100 Subject: [PATCH] If the 'cdrom=' option is specified in the definition file but media is not found in the CD drive then main() in vl.c exits and the guest appears to hang. This patch modifies vl.c slightly to check for the presents of media. If the cdrom cannot be opened then the cd entry is removed from hd_filename[] and bs_table[] allowing the guest to continue initializing. If the guest requires the CD media then the guest should report, gracefully or otherwise, that it's missing. From: Ross Maxfield Signed-off-by: Keir Fraser --- tools/ioemu/vl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c index da009dd11b..d4f305f178 100644 --- a/tools/ioemu/vl.c +++ b/tools/ioemu/vl.c @@ -3245,8 +3245,17 @@ int main(int argc, char **argv) /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); if (has_cdrom) { - bs_table[2] = bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); + int fd; + if ( (fd = open(hd_filename[2], O_RDONLY | O_BINARY)) < 0) { + hd_filename[2]=NULL; + bs_table[2]=NULL; + fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]); + } + else { + close(fd); + bs_table[2] = bdrv_new("cdrom"); + bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); + } } /* open the virtual block devices */ -- 2.30.2